﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PromoOffersCrawler.Crawler.ExtensionMethods;

namespace PromoOffersCrawler.Crawler.Managers
{
    public class ProgressManager
    {
        public int CurrentOpertaion { get; private set; }
        public int TotalOperation { get; private set; }

        public int CalculateOverwallProgress()
        {
            if (TotalOperation > 0)
            {
                return CurrentOpertaion / TotalOperation * 100;
            }
            return 0;
        }

        public void ReportProgress()
        {
            if (CurrentOpertaion < TotalOperation)
            {
                CurrentOpertaion++;
            }
        }

        public void InitializeTotalOperation(int totalOpertations)
        {
            TotalOperation = totalOpertations;
            if (totalOpertations < CurrentOpertaion)
            {
                CurrentOpertaion = totalOpertations;
            }
        }
    }
}
